#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		int sum = 0;
		while (n!=1) {
			if (n % 2 == 1 && n!=1) {
				if (sum == 0) {
					cout << n;
				}
				else {
					cout << " " << n;
				}
				n = n * 3 + 1;
				sum++;
			}
			else {
				n /= 2;
			}
		}
		if (sum == 0) {
			cout << "No number can be output !" << endl;
		}
		else {
			cout << endl;
		}
	}
	return 0;
}